<style type="text/css">
    .demo-upload-list {
        display: inline-block;
        width: 60px;
        height: 60px;
        text-align: center;
        line-height: 60px;
        border: 1px solid transparent;
        border-radius: 4px;
        overflow: hidden;
        background: #fff;
        position: relative;
        box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
        margin-right: 4px;
    }

    .demo-upload-list img {
        width: 100%;
        height: 100%;
    }

    .demo-upload-list-cover {
        display: none;
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(0, 0, 0, .6);
    }

    .demo-upload-list:hover .demo-upload-list-cover {
        display: block;
    }

    .demo-upload-list-cover i {
        color: #fff;
        font-size: 20px;
        cursor: pointer;
        margin: 0 2px;
    }

    .selected-search {
        border: 1px solid #dddee1;
        height: 200px;
        width: 260px;
        position: relative;
        border-radius: 4px;
    }

    .selected-search .search-action {
        position: absolute;
        top: 10px;
        left: 10px;
        right: 10px;
    }

    .selected-search .selected-arr {
        position: absolute;
        top: 50px;
        left: 20px;
        right: 20px;
        bottom: 10px;
        overflow: scroll;
    }

    .select-click {
        border: 1px solid #dddee1;
        border-radius: 4px;
        padding: 0 10px;
        margin-bottom: 10px;
    }

    .selected-search .selected-arr .selected-item {
        /*border-bottom: 1px solid #dfdfdf;*/
    }

</style>
<template>
    <i-form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="100">
        <Form-item label="车牌号" prop="platenum">
            <i-input v-model="formValidate.platenum" placeholder="请输入车牌号"></i-input>
        </Form-item>
        <Form-item label="车辆卡编号" prop="cardid">
            <i-input v-model="formValidate.cardid" placeholder="请输入车辆卡编号"></i-input>
        </Form-item>
        <Form-item label="车辆自编号" prop="carcode">
            <i-input v-model="formValidate.carcode" placeholder="请输入车辆自编号"></i-input>
        </Form-item>
        <Form-item label="车辆车架号" prop="carsn">
            <i-input v-model="formValidate.carsn" placeholder="请输入车辆车架号"></i-input>
        </Form-item>
        <Form-item label="车身颜色" prop="color">
            <i-select v-model="formValidate.color" placeholder="请选择车身颜色">
                <template v-for="(item,index) in colorArr">
                    <i-option :value="item">{{item}}</i-option>
                </template>
            </i-select>
        </Form-item>
        <Form-item label="车辆品牌" prop="brand">
            <i-select v-model="formValidate.brand" placeholder="请选择车量品牌">
                <template v-for="(item,index) in brandArr">
                    <i-option :value="item">{{item}}</i-option>
                </template>
            </i-select>
        </Form-item>
        <Form-item label="行驶里程数" prop="drivedmiles">
            <i-input v-model="formValidate.drivedmiles" placeholder="请输入行驶里程数"></i-input>
        </Form-item>
        <Form-item>
            <i-button @click="handleSubmit('formValidate')" type="primary">下一步</i-button>
            <i-button type="ghost" @click="jumpPage()" style="margin-left: 8px">返回</i-button>
        </Form-item>
    </i-form>
</template>
<script>
    import apiUtil from '../../assets/utils/api_util';
    import baseUtil from '../../assets/utils/base-util';


    /**
     *  车牌号 platenum, 车辆卡编号 cardid，
     *  车辆自编号 carcode, 车辆车架号 carsn,
     *  车身颜色 color， 车辆品牌 brand
     *  参数: 行驶里程数 drivedmiles
     */


    export default {
        data() {
            return {
                formValidate: {
                    //添加字段
                    platenum: '',
                    cardid: '',
                    carcode: '',
                    carsn: '',
                    color: '',
                    brand: '',
                    drivedmiles: '',
                },
                colorArr: ['红', '橙', '黄', '绿', '青'],
                brandArr: ['大众', '奔驰', '宝马', '红旗'],
                ruleValidate: {},
            }
        },
        components: {},
        mounted: function () {
            // this.uploadList();
        },
        methods: {
            //跳转
            jumpPage: function (id, url) {
                this.$router.back(-1)

            },
            handleSubmit(name) {

                let that = this;
                let model = this.$refs[name].model;
                this.$refs[name].validate((valid) => {
                    that.addData(model);
                })
            },
            //添加
            addData: function (model) {
                let that = this;

                let params = that.$qs.stringify(model);
                this.$Loading.start();

                apiUtil.post(that, apiUtil.urls.AddCarInfo, params, function (res) {
                    that.$Loading.finish();

                    baseUtil.pageJump(that, res.Msg, 'CarAdd2');
                    // that.$Modal.confirm({
                    //     title: '操作成功',
                    //     content: '请选择下一步操作',
                    //     okText: '继续添加',
                    //     cancelText: '返回列表',
                    //     onOk: () => {
                    //         that.$router.go(0);
                    //     },
                    //     onCancel: () => {
                    //         baseUtil.pageJump(that, '', 'DriverList')
                    //     }
                    // });

                });
            },

        }
    }
</script>
